<?php
include_once('../lib/Sqlexecutor.php');
include_once('../lib/Notifaction.php');
include('log4php/Logger.php');

Logger::configure('config.ini');
$logger = Logger::getLogger('intf');

$dbh = new Sqlexecutor('localhost', 'tile', 'tile', 'tile');


$token = isset($_REQUEST['token']) ? $_REQUEST['token'] : '';

$token = trim($token, '<');
$token = trim($token, '>');
$token = str_replace(' ', '', $token);

$n = new Notifaction($dbh, $logger);

$rst = $n->save($token);

if($rst >= 0)
{
    $res['errno'] = 0;
}
else
{
    $res['errno'] = $rst;
}
$output = json_encode($res);
$logger->trace("input: token=$token; res: $output");
echo $output;
